<template>
	<view>
		<view class="main">		
			<view class="top">
				<view class="cu-avatar round lg margin-right"  :style="{backgroundImage: 'url('+ $wanlshop.oss(user.avatar, 42, 42, 2) +')'}"></view> 
				<view class="user" @tap="$wanlshop.auth('/pages/user2/partner/storeinfo')">
				   <text style="float: left;">{{user.nickname}} </text>
				   <image style="width: 50rpx;height: 50rpx;float: left;margin-left: 10px;" :src="$wanlshop.oss('/OSS/20240812/d15084649dad243796f766b2b2f85e97.png',40,40,1,'image','png')"></image><br/> 
				   <text class="rq" style="display: inline-block;">vip至：{{$wanlshop.timeFormat(user.vipend)}}</text>
				</view>	
				
			</view>
			
			<view class="image">
				<view class="t1 t3" @tap="$wanlshop.auth('/pages/user2/partner/store/income')">
					<view>累计收益(元)</view>
					<view class="sz">{{user.money}}</view>
					<view class="btm">今日收益(元)&nbsp;&nbsp;|&nbsp;&nbsp;{{todayIncome}}</view>				
					
				</view>
				<view class="t2 t3"  @tap="$wanlshop.auth('/pages/user2/partner/offlines')">
					<view>累计邀请(人)</view>
					<view class="sz">{{totalOffline}}</view>
					<view class="btm">今日邀请(人)&nbsp;&nbsp;|&nbsp;&nbsp;{{todayOffline}}</view>
				</view>
				
			</view>
			
			
		       
			<view class="title">门店管理</view>
			<view class="order" style="clear: both;color: #6C3E24;">
				<view  v-for="(item, index) in stores" style="clear: both;height: 70px;padding: 10px;position: relative;">
					<view @tap="$wanlshop.auth('/pages/user2/partner/store/index?id='+item.id)" class="cu-avatar round lg margin-right"  :style="{backgroundImage: 'url('+ $wanlshop.oss(item.image, 62, 62, 2) +')',float: 'left'}"></view> 
					<view @tap="$wanlshop.auth('/pages/user2/partner/store/index?id='+item.id)" style="float: left;color: wheat;margin-top: 3px;">
						<view>{{item.store}}<text style="font-size: 13px;color: aquamarine;">(店长:{{item.storeManager}})</text></view>
						<text style="color: darkgray;">{{item.address_city}}</text>
					</view>
					<text @tap="changeManage(item.id, index)" style="position: absolute;right: 10px;top: 20px;font-size:12px;color: aquamarine;">更换店长</text>
				</view>				
				<view style="clear: both;"></view>
			</view>
			
			
			
			
			
			<view class="title">合伙人权益</view>
			<view class="list">
				<view class="item">
					<view class="t">
						<image class="image" :src="$wanlshop.oss('/OSS/20240809/335db9e68883e6cbecad0ab005340ed9.png',40,40,1,'image','png')"></image>
					</view>			
					<view class="b">合伙人<br/>协议</view>
				</view>
				<view class="item">
					<view class="t">
						<image class="image" src="/static/images/vip/icon-1.png"></image>
					</view>			
					<view class="b">无上限<br/>会员绑定</view>
				</view>
				<view class="item">
					<view class="t">
						<image class="image" src="/static/images/vip/icon-2.png"></image>
					 </view>
					<view class="b" style="padding-top: 23px;">高额分佣<br/></view>
				</view>

			</view>
			<view style="clear: both;"></view>
	    </view>
		<view class="task">
			<view class="fg"></view>
			<text class="ti">重要通知</text>
			<view class="con">
				<view class="cu-list menu-avatar" v-if="notices">
					<view class="cu-item" style="display: block;line-height: 2;margin-top: 10px;height: 110rpx;" v-for="(item, index) in notices" :key="item.id">		
						<view @tap="$wanlshop.auth(item.type1 == 'share'?'/pages/user2/partner/offlines':(item.modules == 'notice'?('/pages/notice/notify/notice?id='+item.id):('/pages/user/order/details?id='+item.modules_id)))">
							<view class="text-sm flex">
								<view class="text-cut" style="max-width: 100%;font-size: 28rpx;">
									{{item.title}}
								</view> 
							</view>
							<view class="wanl-gray text-sm text-bold" style="float: left;">{{item.type1?type1[item.type1]:''}}</view>
							<view class="wanl-gray text-sm" style="float: right;">
								{{ $wanlshop.timeToDate(item.createtime) }}
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		
	</view>
	
</template>

<script>
	import { mapState } from 'vuex';
	export default {
		data() {
			return {
				todayIncome:0,
				todayYincome:0,
				todayOffline:0,
				totalOffline:0,
				notices:{},
				stores:[],
				type1: {
					order: '下线订单',
					cush: '交易分佣',
					share: '分享注册'
				}
			}
		},
		computed: {
			...mapState(['user'])		
		},
		onLoad() {
			
		},
		onShow() {
			this.getOfflinesNumber();
		},
		methods: {
			getOfflinesNumber(){
				uni.request({
					url: '/wanlshop/user/getStore',			       
					success: res => {
						this.todayIncome = res.data.todayIncome;	
						this.todayYincome = res.data.todayYincome;	
						this.todayOffline = res.data.todayOffline;	
						this.totalOffline = res.data.totalOffline;
						this.notices = res.data.notices;
						this.stores = res.data.stores;
						if(!this.stores){
							this.$wanlshop.to('/pages/user2/partner/store/index?id='+this.user.store.id);
						}
					}
			    }) 
			},
			changeManage(id,index){
				console.log(index);
				// 显示弹出框
				uni.showModal({
					title: '请输入已注册手机号码',
					content: '',
					editable: true, //是否显示输入框
					placeholderText: '请输入已注册手机号码', //输入框提示内容
					confirmText: '确认',
					cancelText: '取消',
					success: (res) => {
						if (res.confirm) {
							let mobile_= /^1\d{10}$/;
							if(!mobile_.test(res.content)){
								this.$wanlshop.msg('请输入正确的手机号码');
								return false;
							}
							uni.request({
								url: '/wanlshop/ddp/changeManage',
								data: {id:id,mobile:res.content},
								method:'POST',
								success: res => {
									this.stores[index].storeManager = res.data.nickname;	
									this.$wanlshop.msg('更换成功');
								},
								error:res => {
									return false;
								}
							});
						}
					}
				});
			}
			
		}
	}
</script>

<style>
	.main{
		font-family: OPPOSans Medium;
		background-color: #B75D62;
		padding: 40rpx;
		position: relative;
		padding-bottom: 40px;
		padding-top: 20rpx;
	}
	.main .top{
		left: 16rpx;
		top: 26rpx;
		display: flex;
	}
	.top .cu-avatar,.top .user{
		font-size: 32rpx;
		float: left;
		margin-left: 5px;
		position: relative;
		line-height: 50rpx;
	} 
	.top .cu-avatar,.top .user .rq{
		font-size: 30rpx;
	} 
	.top .cu-avatar{
		width: 100rpx;
		height: 100rpx;
		margin: 8rpx;
	}
	.top .user{
		margin-top: 8rpx;
		color: #F7CEB1;
	}
	.main .image{
		clear: both;
		margin-top: 15px;
		display: flex;
		color: #7B523A;
	}
	.main .image .t1{
		width: 48%;
		height: 186rpx;
		margin-right: 4%;
		border-radius: 5px;
		background-image: url('https://dundunpai.oss-cn-beijing.aliyuncs.com/OSS/20240809/2c16db36649d2ae4195fd62c8d22454c.png');
		background-size: 100%;
		background-repeat: no-repeat;
		padding: 10rpx;
	}	
	.main .image .t2{
		width: 48%;
		height: 186rpx;		
		border-radius: 5px;
		background-image: url('https://dundunpai.oss-cn-beijing.aliyuncs.com/OSS/20240809/41759c1270009a35fa6925c720f6e8f6.png');
		background-size: 100%;
		background-repeat: no-repeat;
		padding: 10rpx;
	}
	.main .image .t3 .sz{
		color: #F54D4C;
		font-weight: 600;
		font-size: 18px;
		padding-left: 10px;
	}
	.main .image .t3 .btm{
		margin-top: 15px;
	}
	.main .title{
		margin: 30rpx 0;
		color: #F7CEB1;
		font-size: 34rpx;
	}
	.main .list .item{
		width: 210rpx;
		float: left;
		margin-right: 16rpx;
		text-align: center;
		background-color: #CE7976;
		border-radius: 5px;
		overflow: hidden;
	}
	.main .list .item:last-child{
		margin-right: 0;
	}
	.main .list .t{
		text-align: center;
		padding: 15px 0 10px 0;	
	}
    .main .list .item .t .image{		
		width:90rpx;
		height: 90rpx;
		margin: 0 auto;
	}
	.main .list .b{
		background-image: url('/static/images/vip/bg.png');
		background-repeat: no-repeat;
		height: 110rpx;
		padding-top: 15px;	
		background-size: 110%;	
		font-size: 26rpx;	
		color: #7B4D33;
		
	}
	.task{
		position: relative;
		background-color: white;
		height: 750rpx;
		padding-top: 10px;
	}
	.task .fg{
		position: absolute;
		left: 0;
		top: -22rpx;
		background-color: white;
		border-radius: 15px 15px 0 0 ;		
		background-repeat: no-repeat;
        text-align: center;
		height: 26rpx;
		line-height: 70rpx;
		font-size: 39rpx;
		background-size: 50%;
		background-position: center;
		padding-top: 20rpx;
		width: 100%;
		color: #2B2221;		
	}
	.task .ti{
		margin-left: 52rpx;	
		background-color: #FF5D5D;
	    color: white;
		padding: 0 12rpx;
		font-size: 28rpx;
		border-radius: 6rpx;
	}
	.task .con{
		padding: 0 52rpx;
	}
	.task .list{
		min-height: 500rpx;
		background-color: white;
		padding: 30rpx;
		padding-top: 90rpx;
	}
	.task .list .item{
		margin-bottom: 30rpx;
		background-color: #FCB2B4;
		color: #F4B59F;
		padding: 50rpx 30rpx;
		font-size: 32rpx;
		font-family: 微软雅黑;
		border-radius: 20px;
		position: relative;
	}
	.task .list .item .bt{
		position: absolute;
		top: 40rpx;
		right: 30rpx;
		background-color: #F7D1B6;
		border-radius: 30px;
		padding: 10rpx 20rpx;
		float: right;
		color: #E84C4A;
		font-size: 34rpx;
	}
	.order .item{
		width: 30%;
		margin-right: 3%;
		padding: 5px 10px;
		background-color: #CE7976;
		float: left;
		text-align: center;
		border-radius: 3px;
		color: #F7CEB1;
		font-weight: 600;
	}
</style>
